#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll T,v[N],d[N],a[N],m[N],res1,res2;
ll n,M,L,V;
bool f[N];
void dfs(ll dep,ll cnt){
	if(dep>M){
		ll sum=0;
		for(int i=1;i<=n;i++){
			if(d[i]>m[M]) continue;
			for(int j=1;j<=M;j++){
				if(f[j]==1) continue;
				if(m[j]<d[i]) continue;
				if(a[i]<0 && 1.0*v[i]*v[i]/(2.0*-a[i])<=m[j]-d[i]) continue;
				double vx=sqrt(1.0*v[i]*v[i]+2.0*a[i]*(m[j]-d[i]));
				if(vx>1.0*V){
					sum++;
					break;
				}
			}
		}
		if(sum==res1){
			res2=max(res2,cnt);
		} 
		return;
	}
	dfs(dep+1,cnt);
	f[dep]=1;
	dfs(dep+1,cnt+1);
	f[dep]=0;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>T;
	while(T--){
		bool f1=1,f2=1,f3=1;
		res1=res2=0;
		memset(f,0,sizeof f);
		cin>>n>>M>>L>>V;
		for(int i=1;i<=n;i++){
			cin>>d[i]>>v[i]>>a[i];
			if(a[i]!=0) f1=0;
			if(a[i]<=0) f2=0;
			if(a[i]>=0) f3=0;
		}	
		for(int i=1;i<=M;i++)	cin>>m[i];
		for(int i=1;i<=n;i++){
			if(d[i]>m[M]) continue;
			if(a[i]>0){
				if(sqrt(1.0*v[i]*v[i]+2.0*a[i]*(m[M]-d[i]))>1.0*V) res1++;
			}
			if(a[i]==0){
				if(v[i]>1.0*V) res1++;
			}
			if(a[i]<0){
				ll p=lower_bound(m+1,m+M+1,d[i])-m;
				if(1.0*v[i]*v[i]/(2.0*-a[i])<=m[p]-d[i]) continue;
				double vx=sqrt(1.0*v[i]*v[i]+2.0*a[i]*(m[p]-d[i]));
				if(vx>1.0*V)	res1++;
			}
		}
		if(f1==1)	cout<<res1<<" "<<M-1<<endl;
		else if(f2==1) 	cout<<res1<<" "<<M-1<<endl;
		else if(f3==1)	cout<<res1<<" "<<M-1<<endl;
		else{
			dfs(1,0);
			cout<<res1<<" "<<res2<<endl;
		}
	}
	return 0;
}
